package servlet;

import dao.StartCourseDao;
import vo.StartCourse;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by ssw on 2018/6/19.
 */
public class AddSCServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//       cname 课程编号
        String cno=req.getParameter("cname");
        String lid=req.getParameter("lname");
        String clname=new String(req.getParameter("clname").getBytes("ISO-8859-1"),"UTF-8");
        String scroom=new String(req.getParameter("scroom").getBytes("ISO-8859-1"),"UTF-8");
        String sctime=new String(req.getParameter("sctime").getBytes("ISO-8859-1"),"UTF-8");
        String sccredit=req.getParameter("sccredit");
        StartCourseDao startCourseDao=new StartCourseDao();
        boolean res=startCourseDao.addsc(cno,lid,clname,scroom,sctime,sccredit);
        if(res)
            req.getRequestDispatcher("sgms/admin_addsc.jsp?res=1").forward(req,resp);
        else
            req.getRequestDispatcher("sgms/admin_addsc.jsp?res=0").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
